<?php
	$EventModelObj = cri('Event');
	$fieldproperies = $EventModelObj->fieldProperties;
	$showFields = $EventModelObj->getFields('group','add');
?>
<?php
$i = 0;
foreach($fieldproperies as $field=>$fieldInfo)
{
	if(isset($fieldInfo['fieldset_name']))
	{
		if($EventModelObj->getFieldProperties($field,'type') == 'multipleCheckbox')
		{
			$fieldInfo['div'] = 'checkbox_group';
		}
		$newFieldproperies[$fieldInfo['fieldset_name']][$i][$field] = $fieldInfo;
		$newFieldproperies[$fieldInfo['fieldset_name']]['fieldsetInfo']['fieldset_id'] = $fieldInfo['fieldset_id'];
		$newFieldproperies[$fieldInfo['fieldset_name']]['fieldsetInfo']['fieldset_label'] = $fieldInfo['fieldset_label'];
		$newFieldproperies[$fieldInfo['fieldset_name']]['fieldsetInfo']['fieldset_show_label'] = $fieldInfo['fieldset_show_label'];
		$i++;
	}
}
?>


<?php 
if(!isset($this->params['admin']))
{
	unset($eventDefaultFields['meta_keywords']);
	unset($eventDefaultFields['image']);
	unset($eventDefaultFields['meta_description']);
}
//code to show default fields.
echo $form->inputs(am(array('fieldset'=>false),$eventDefaultFields));

//code to show custom field info starts here
if(!empty($newFieldproperies))
{
	foreach($newFieldproperies as $fieldsetName=>$fieldsetFields)
	{
		$fieldsetOtherInfo = $fieldsetFields['fieldsetInfo'];
		unset($fieldsetFields['fieldsetInfo']);
		?>
<div class="fieldset <?php echo $fieldsetName?>"
	id="fieldset_input_<?php echo $fieldsetOtherInfo['fieldset_id']?>">
	<fieldset>
		<legend>
			<?php
			if($fieldsetOtherInfo['fieldset_show_label'] == 1)
			{
				echo $fieldsetOtherInfo['fieldset_label'];
						}?>
		</legend>
		<?php
		foreach($fieldsetFields as $fields)
		{
			foreach($fields as $field=>$fieldInfo)
			{
				if(in_array($field,$showFields))
							{?>
		<div class="custom_field"
			id="custom_field_<?php echo $fieldInfo['custom_field_id']?>">
			<?php
			$fieldType = $EventModelObj->getFieldProperty($field,'type');
			if($fieldType == SCHEMA_TYPE_VIDEO && isset($eventData) && @$eventData['Event'][$field])
			{
				$video =  $customFieldDisplay->showVideo(null,$eventData['Event'][$field]);
				if($video)
				{

					$videoDomId = "video_show_".rand(1,100);
					$videoWrapperDomId = $videoDomId."_wrapper";
					$video = "<div id=\"$videoDomId\" style='display:none'>$video</div>";
					$videoHtml = $html->link(__("View current video"),'javascript:void(0)',array("onclick"=>"$('#$videoDomId').toggle()"));
					$videoADomId = $videoDomId.'_a';
					$videoHtml .= ' | '.$html->link(__("Delete current video"),array("action"=>"deleteVideo",$eventData['Event']['id'],$field),array("id"=>$videoADomId,'onclick'=>"return false;"));
					$msg = __("Are you sure you want to delete this video?");
					$js=<<<JS
                                          \$('#$videoADomId').click(function(){
                                              if(confirm("$msg"))
                                              {
                                                \$.get(\$(this).attr('href'));
                                                \$('#$videoWrapperDomId').hide('slow');
                                              }
                                              return false;
                                          })
JS;
					$javascript->startup($js);
					$videoHtml .= $video;
					$fieldInfo['after'] = "<div id='$videoWrapperDomId'>".$videoHtml.'</div>';
				}
			}
			?>

			<?php echo $form->input($field,$fieldInfo);?>
		</div>
		<?php
							}
			}
					}?>
	</fieldset>
</div>
<?php 
	}
}
//code to show custom field info ends here
?>